define(
		[ "PDUtilDir/util", "PDUtilDir/grid" , "PDUtilDir/slidebar"],
		function(Util, Grid, Slidebar) {
			function detailSupportInit($scope, $compile){
				return new detailSupport($scope, $compile);
			}
			function detailSupport($scope, $compile){
				var _this = this;
				this.entity = {
					trip : [],
					lineId: "",
					timetable : new Array(),
					explain : {}
				};
				this.cache = {};
				this.bind = {
					trip : {},
					tripTimestampArray_tmp : new Array(),
					tripMap : {},
					timetable : {}
				};
				this.$scope = $scope;
				this.$compile = $compile;
			}
			detailSupport.fn = detailSupport.prototype;
			detailSupport.fn.digest = function(){
				 this.$scope.$digest();
			 }
			detailSupport.fn.run = function(id) {
				var _this = this;
				_this.cache.id = id;
				this.slidebars = Slidebar({
					size : 'lg',
					url : getServer()
							+ "/static/app/group/groupInfos/views/detail.html",
//					close : true,
					$scope: this.$scope,
					$compile: this.$compile,
					afterLoad : function($Panel) {
						_this.initialization();
					}
				});
			};
			detailSupport.fn.initialization = function(){
				this.baseInit();
			};
			detailSupport.fn.exportFun = function(){
				var _this = this;
				Util.confirm("确认导出？", function() {
					 var url = getServer() + "/flea/hclv/htravelGroup/getAllPersonByGroupIdOutExcel.htmls?model=" + _this.cache.id;
				        form = $("<form></form>").attr("action", url).attr("method", "post");
				        form.appendTo('body').submit().remove();
				});
			};
			detailSupport.fn.baseInit = function() {
				var _this = this;
				if(!_this.cache.certificates){
					$.ajax({
						url : getServer() + "/flea/hclv/getCertificates.htmls",
						success : function(data) {
							_this.cache.certificates = data.data;
							_this.grid.refresh();
						}
					});
				}
				_this.grid = Grid({
					id : "PersonInGroupGirdDivId",
					pageSize : 10,
					index : true,
//					multi : true,
					pagination : true,
					cache : false,
					layout : [ {
						name : "中文名",
						field : "zhName",
						sort : true
					}, {
						name : "英文名",
						field : "enName",
						sort : true
					}, {
						name : "代码",
						field : "code",
						sort : true
					}, {
						name : "性别",
						field : "sex"
					}, {
						name : "年龄",
						field : "age"
					}, {
						name : "联系电话",
						field : "phone"
					}, {
						name : "证件类型",
						field : "certificates",
						format:function(e){
							if(!_this.cache.certificates)
								return;
							for(var i=0;i<_this.cache.certificates.length;i++){
								if(_this.cache.certificates[i].dictCode==e.row.certificates){
									return _this.cache.certificates[i].dictName;
								}
							}
						}
					}, {
						name : "证件号码",
						field : "certificatesNumber"
					} ],
					toolbar : [ {
						name : "导出",
						icon : "fa fa-download",
						callback : function(event) {
							_this.exportFun();
						}
					} ],
					data : {
						type : 'URL',
						value : getServer() + '/flea/hclv/htravelGroup/getAllPersonByGroupId.htmls'
					},
					queryParam: {
						model: _this.cache.id
					}
				});
			};
			detailSupport.fn.save = function() {
				var _this = this;
				$.ajax({
                    url : getServer() + "/flea/hclv/product/save.htmls",
                    data : {
                        'model' : JSON.stringify(_this.entity)
                    },
                    success : function(data) {
                    	_this.$scope.grid.refresh();
                        Util.alert('成功');
                        _this.slidebars.close();
                    }
				});
			};
			return detailSupportInit;
		});